package demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

public class test1 {
	
	private Stack<Integer> stack;
	
	private int min;
	
	
	public static void main(String[] args) {
		
    }
	 
    public void MinStack() {
    	stack = new Stack<Integer>();
    	min = Integer.MAX_VALUE;
    }
    
    public void push(int x) {
        stack.push(x);
        if(x < min){
        	min = x;
        }
        
    }
    
    public void pop() {
        int temp = stack.peek();
        stack.pop();
        if(min == temp){
        	min = Integer.MAX_VALUE;
        	for(int i = 0; i < stack.size(); i++){
        		if(stack.get(i) < min){
        			min = stack.get(i);
        		}
        	}
        }
    }
    
    public int top() {
        return stack.peek();
    }
    
    public int getMin() {
        return min;
    }
}
